package xin.clips.system.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;
import xin.clips.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xin.clips.common.core.text.Convert;
import xin.clips.system.domain.gy.GyDeviceMgt;
import xin.clips.system.mapper.SysUserMapper;
import xin.clips.system.mapper.gy.GyDeviceMgtMapper;
import xin.clips.system.service.gy.IGyDeviceMgtService;

/**
 * 设备消息绑定Service业务层处理
 *
 * @author yuanzy
 * @date 2023-02-26
 */
@Service
public class GyDeviceMgtServiceImpl implements IGyDeviceMgtService
{
    @Autowired
    private GyDeviceMgtMapper gyDeviceMgtMapper;
    @Autowired
    private SysUserMapper sysUserMapper;
    /**
     * 查询设备消息绑定
     *
     * @param id 设备消息绑定主键
     * @return 设备消息绑定
     */
    @Override
    public GyDeviceMgt selectGyDeviceMgtById(Long id)
    {
        return gyDeviceMgtMapper.selectGyDeviceMgtById(id);
    }

    /**
     * 查询设备消息绑定列表
     *
     * @param gyDeviceMgt 设备消息绑定
     * @return 设备消息绑定
     */
    @Override
    public List<GyDeviceMgt> selectGyDeviceMgtList(GyDeviceMgt gyDeviceMgt)
    {
        return gyDeviceMgtMapper.selectGyDeviceMgtList(gyDeviceMgt);
    }

    /**
     * 新增设备消息绑定
     *
     * @param gyDeviceMgt 设备消息绑定
     * @return 结果
     */
    @Transactional
    @Override
    public int insertGyDeviceMgt(GyDeviceMgt gyDeviceMgt)
    {

        gyDeviceMgt.setCreateTime(DateUtils.getNowDate());
        return gyDeviceMgtMapper.insertGyDeviceMgt(gyDeviceMgt);
    }

    /**
     * 修改设备消息绑定
     *
     * @param gyDeviceMgt 设备消息绑定
     * @return 结果
     */
    @Override
    public int updateGyDeviceMgt(GyDeviceMgt gyDeviceMgt)
    {
        gyDeviceMgt.setUpdateTime(DateUtils.getNowDate());
        return gyDeviceMgtMapper.updateGyDeviceMgt(gyDeviceMgt);
    }

    /**
     * 批量删除设备消息绑定
     *
     * @param ids 需要删除的设备消息绑定主键
     * @return 结果
     */
    @Override
    public int deleteGyDeviceMgtByIds(String ids)
    {
        return gyDeviceMgtMapper.deleteGyDeviceMgtByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除设备消息绑定信息
     *
     * @param id 设备消息绑定主键
     * @return 结果
     */
    @Override
    public int deleteGyDeviceMgtById(Long id)
    {
        return gyDeviceMgtMapper.deleteGyDeviceMgtById(id);
    }


    /**
     * 查询设备消息绑定
     *
     * @param deviceType 设备类型
     * @return 设备消息绑定
     */
    public List<GyDeviceMgt> selectGyDeviceMgtByDeviceType(Integer deviceType){
        return  gyDeviceMgtMapper.selectGyDeviceMgtByDeviceType(deviceType);
    }
}
